﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.actions {
    import Engine.Classes.*;
    import flash.geom.*;
    import Classes.*;

    public class BaseResourceAction extends NPCAction {

        protected var m_resource:MapResource;
        protected var m_actionStarted:Boolean;
        protected var m_actionTime:Number = 0;

        public function BaseResourceAction(_arg1:NPC=null, _arg2:MapResource=null){
            super(_arg1);
            this.m_resource = _arg2;
        }
        public function getResource():MapResource{
            return (this.m_resource);
        }
        override public function added():void{
            super.added();
            if (this.m_resource){
                this.m_resource.lock();
            };
        }
        override public function removed():void{
            super.removed();
            if (this.m_resource){
                this.m_resource.unlock();
            };
        }
        override public function enter():void{
            super.enter();
            this.goToActionPosition();
            this.m_actionStarted = true;
        }
        override public function reenter():void{
            this.goToActionPosition();
            this.m_actionStarted = true;
        }
        override public function exit():void{
            if (m_npc){
                m_npc.setActionProgress(false);
                m_npc.setActionBarOffset(0, 0);
            };
            super.exit();
        }
        protected function goToActionPosition():void{
            var _local1:Point = this.getActionPosition();
            if (((!((_local1 == null))) && (m_npc))){
                m_npc.setPosition(_local1.x, _local1.y);
            };
        }
        protected function getActionPosition():Point{
            return (((this.m_resource)!=null) ? this.m_resource.getPosition().toVector2() : new Point());
        }
        override public function getInterrupt():int{
            return ((this.m_actionStarted) ? State.NO_INTERRUPT : State.NORMAL_INTERRUPT);
        }

    }
}//package Classes.actions 
